public class TwoSum {
    public int[] twoSum(int[] price, int target) {
        int n = price.length;
        int left = 0, right = n - 1;
        while(left < right) {
            if(price[left] + price[right] > target) {
                right--;
            }else if(price[left] + price[right] < target){
                left++;
            }else {
                return new int[]{price[left], price[right]};
            }
        }
        return new int[0];
    }
}
